﻿using System;
using System.Windows.Markup;

namespace Iworld.Toolkit.Markup
{
    /// <summary>
    /// 扩展标记基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class MarkupBase<T> : MarkupExtension
    {
        /// <summary>
        /// 默认的输入值
        /// </summary>
        public string Value { set; get; }

        public MarkupBase() { }

        public MarkupBase(string value) 
        {
            this.Value = value;
        }

        public sealed override object ProvideValue(IServiceProvider serviceProvider)
        {
            IProvideValueTarget ivt = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));
            return this.ProvideValueInternal(ivt,serviceProvider);
        }

        protected abstract T ProvideValueInternal(IProvideValueTarget provideValueTarget,IServiceProvider serviceProvider);
 
    }
}
